<?php

use think\facade\Route;

$miss = function () {
    $arr = [
        'code' => -1,
        'msg' => '请输入正确的路由地址',
        'data' => []
    ];
    return json($arr);
};
// 主页路由
Route::miss($miss);
// 只需要验证token的放在一起
$func = function () {
    //用户
    Route::group('/union/member', function () {
        //用户详情
        Route::get('info', 'home.Member/info');
        //切换身份
        Route::post('change', 'home.Member/change');
        //一周业绩
        Route::get('week_order', 'home.Member/week_order');
        //打卡
        Route::post('clock', 'home.Member/clock');
        //绑定手机号
        Route::post('bindPhone', 'home.Member/bindPhone');
    });
    //助教
    Route::group('/union/assistant', function () {
        //列表
        Route::get(':store_id', 'home.Assistant/query');
        //详情
        Route::get('detail/:id', 'home.Assistant/detail');
        //申请
        Route::post('', 'home.Assistant/create');
    });
    //道具
    Route::group('/union/prop', function () {
        //列表
        Route::get('', 'home.Prop/query');
        //用户赠送的道具
        Route::get('memberGiven', 'home.PropMember/query');
    });
    //道具使用记录
    Route::group('/union/propUse', function () {
        //列表
        Route::get('', 'home.PropUse/query');
    });
    //房间列表
    Route::group('/union/room', function () {
        Route::get(':store_id', 'home.Room/query');
        Route::get('detail/:id', 'home.Room/detail');
    });
    //预约
    Route::group('/union/book', function () {
        //预约
        Route::post('', 'home.Book/create');
        //详情
        Route::get('detail', 'home.Book/detail');
        //我的预约
        Route::get('my', 'home.Book/my');
        //同意预约
        Route::put(':id/approve', 'home.Book/enable');
        //拒绝预约
        Route::put(':id/reject', 'home.Book/disable');
    });
    //订单
    Route::group('/union/order', function () {
        Route::get('', 'home.Order/query');
        Route::post('', 'home.Order/create');
        Route::get('mycart', 'home.Order/mycart');
        Route::put('updateOrder', 'home.Order/update');
        //余额支付
        Route::post('payWithBalance', 'home.Order/balancePay');
        //清空购物车
        Route::put('clearCart', 'home.Order/clearCart');
    });
    //支付
    Route::group('/union/pay', function () {
        Route::post('', 'home.WxPay/pay');
        Route::post('notify', 'home.WxPay/notify');
    });
    //值班
    Route::group('/union/duty', function () {
        //报班
        Route::post('', 'home.Duty/create');
        //我的报班
        Route::get('', 'home.Duty/query');
        //抛班
        Route::post('disable/:id', 'home.Duty/disable');
        //顶班
        Route::post('enable/:id', 'home.Duty/enable');
        //每周当值
        Route::get('week', 'home.Duty/week');
    });
    //门店
    Route::group('/union/store', function () {
        //我的门店列表
        Route::post('my', 'home.Store/my');
    });
    //Cp
    Route::group('/union/cp', function () {
        //申请
        Route::post('', 'home.Cp/create');
        //未绑定助教列表
        Route::get('get_asssistant', 'home.Cp/get_unbind_assistant');
        //我的对象
        Route::get('my', 'home.Cp/my');
        //解绑
        Route::put('unbind', 'home.Cp/unbind');
    });
    //头像框
    Route::group('/union/avatar_frame', function () {
        Route::get('', 'home.AvatarFrame/query');
        Route::put(':frame_id', 'home.Member/change_avatar');
    });
    //消息通知
    Route::group('/union/notice', function () {
        //预约通知助教
        Route::post('book_to_assistant', 'home.WxMessage/book_to');
    });
};
//微信小程序授权登录
Route::post('/union/wxlogin', 'home.WxMini/wxlogin');
//轮播图
Route::get('/union/banner', 'home.Banner/query');
//公告
Route::get('/union/notice', 'home.Notice/query');
//随机列表
Route::get('/union/assistant/random', 'home.Assistant/random');
//微信模板列表
Route::get('/union/wx_template', 'home.WxTemplate/query');
//发送短信
Route::post('/union/sendSms', 'home.Sms/sendMessage');
//腾讯短信
Route::post('/union/sendTxSms', 'home.TxSms/send');
//门店
Route::group('/union/store', function () {
    //列表
    Route::get('', 'home.Store/query');
    //详情
    Route::get(':id', 'home.Store/detail');
})->completeMatch(true);
//游戏列表
Route::get('/union/game', 'home.Game/query');
Route::group('', $func)->middleware(app\common\middleware\TokenCheck::class)->allowCrossDomain()->completeMatch(true);
